<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
    "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<meta http-equiv="Content-Type" content="text/html;charset=utf-8" />
<link rel="stylesheet" href="../style/journal.css" type="text/css" />
<style type="text/css"><!--
.googleadsense {
	margin: 2px;
	padding: 0px;
//--></style><script src="http://www.google-analytics.com/urchin.js" type="text/javascript">
</script>
<script type="text/javascript">
_uacct = "UA-65008-1";
urchinTracker();
</script><title>Module</title>
</head>
<body>
<a href="index.html">Journal</a>(2005) | <a href="../blog/"><b>Blog</b></a>(2006) | <a href="http://www.fayland.org/cgi-bin/random_link.pl">RandomLink</a> | <a href="AboutFayland.html">WhoAmI</a> | <a href="LiveBookmark.html">LiveBookmark</a> | <a href="http://www.fayland.org/">HomePage</a>
<p><&lt;Previous: <a href="PerlTidy.html">PerlTidy</a>&nbsp;&nbsp;>>Next: <a href="Highlight.html">如何将Perl代码着色</a></p>
<h1>Module</h1>
<div class='content'>
<p>Category: <a href='Basic.html'>Basic</a> &nbsp; Keywords: <b>Module</b></p><h2>qw的解释</h2>
use Module qw(argu param);中<font color="red">qw</font>的解释<br>
qw中的内容在本语句执行后，便成为Module里的import函数的参数。例解如下：
<pre>#TEst.pm
package TEst;

sub import {
  print "@_";
}

1;

#test.pl
#!/usr/bin/perl
use TEst qw(argu param);

__OUTPUT__
TEst argu param
</pre>

参考：<a href="http://www.stonehenge.com/merlyn/PerlJournal/col13.html" target="_blank">Randal L. Schwartz's Hey, 'use' guys! Import this!</a>
<h2>查找已安装模块</h2>
<pre>
use ExtUtils::Installed;

my $inst = ExtUtils::Installed->new();
print join "\n", $inst->modules();
</pre>
<h2>检查批量模块是否已安装</h2>
<pre><code>
#!/usr/bin/perl
# Check the needed modules are installed in currect system
print "Content-Type: text/html\r\n\r\n";

while (&lt;DATA>) {
 &nbsp; &nbsp;s/[^\w\:]*//g;
 &nbsp; &nbsp;next unless ($_);
 &nbsp; &nbsp;eval("use $_;");
 &nbsp; &nbsp;if ($@) {
 &nbsp; &nbsp; &nbsp; &nbsp;print "&lt;font color=red>$_&lt;/font> failed to locate.&lt;br>";
 &nbsp; &nbsp;} else {
 &nbsp; &nbsp; &nbsp; &nbsp;print "&lt;font color=blue>$_&lt;/font> locate success!&lt;br>";
 &nbsp; &nbsp;}
}

# add the module name you want to check
__DATA__
strict
CGI::Carp
CGI
Net::SMTP
TEM_P
</code></pre></div>
<p><&lt;Previous: <a href="PerlTidy.html">PerlTidy</a>&nbsp;&nbsp;>>Next: <a href="Highlight.html">如何将Perl代码着色</a></p>
<p><strong>Options:</strong> <a href='http://del.icio.us/post?title=Module&url=http://www.fayland.org/journal/Module.html'>+Del.icio.us</a></p>
<strong>Related items</strong>
<ul><li><a href='Module_Build.html'>用Module::Build制作CPAN模块包</a> < <span class='digit'>2004-12-16 18:59:50</span> ></li><li><a href='UploadModule.html'>如何向CPAN上传模块</a> < <span class='digit'>2004-12-16 19:27:09</span> ></li><li><a href='Synopsis11.html'>纲要十一：模块</a> < <span class='digit'>2005-03-14 15:32:36</span> ></li><li><a href='Notes_on_Creating_Module.html'>关于怎么创建新模块简单的纪录</a> < <span class='digit'>2005-11-17 23:06:03</span> ></li></ul>
Created on <span class="digit">2004-10-30 19:10:08</span>, Last modified on <span class="digit">2005-05-21 00:16:04</span><br />
Copyright 2004-2005 All Rights Reserved. Powered by <a href="Eplanet.html">Eplanet</a> && <a href='http://catalyst.perl.org'>Catalyst</a> 5.62.
</body>
</html>